home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_amanda.idb / usr / freeware / bin / amdump.z / amdump
Encoding:
Text File  |  1999-07-16  |  3.2 KB  |  118 lines

  1. #!/bin/sh
  2. #
  3. # Amanda, The Advanced Maryland Automatic Network Disk Archiver
  4. # Copyright (c) 1991-1998 University of Maryland at College Park
  5. # All Rights Reserved.
  6. #
  7. # Permission to use, copy, modify, distribute, and sell this software and its
  8. # documentation for any purpose is hereby granted without fee, provided that
  9. # the above copyright notice appear in all copies and that both that
  10. # copyright notice and this permission notice appear in supporting
  11. # documentation, and that the name of U.M. not be used in advertising or
  12. # publicity pertaining to distribution of the software without specific,
  13. # written prior permission.  U.M. makes no representations about the
  14. # suitability of this software for any purpose.  It is provided "as is"
  15. # without express or implied warranty.
  16. #
  17. # U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  18. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
  19. # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  20. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  21. # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  22. # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23. #
  24. # Author: James da Silva, Systems Design and Analysis Group
  25. #               Computer Science Department
  26. #               University of Maryland at College Park
  27. #
  28.  
  29. #
  30. # amdump: Manage running one night's Amanda dump run.
  31. #
  32.  
  33. prefix=/usr/freeware
  34. exec_prefix=${prefix}
  35. sbindir=/usr/freeware/bin
  36. libexecdir=/usr/freeware/libexec
  37.  
  38. confdir=/usr/freeware/etc/amanda
  39.  
  40. PATH=$libexecdir:/usr/freeware/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb
  41. export PATH
  42.  
  43. USE_VERSION_SUFFIXES="no"
  44. if test "$USE_VERSION_SUFFIXES" = "yes"; then
  45.     SUF="-2.4.1p1"
  46. else
  47.     SUF=
  48. fi
  49.  
  50. if [ $# -ne 1 ]; then
  51.         echo  Usage: amdump$SUF conf
  52.         exit 1
  53. fi
  54.  
  55. conf=$1
  56. if [ ! -d $confdir/$conf ]; then
  57.     echo "amdump$SUF: could not find directory $confdir/$conf"
  58.     exit 1
  59. fi
  60.  
  61. cd $confdir/$conf
  62.  
  63. logdir=`$libexecdir/getconf$SUF logdir`
  64. errfile=$logdir/amdump
  65. tapecycle=`$libexecdir/getconf$SUF tapecycle`
  66. dumpuser=`$libexecdir/getconf$SUF dumpuser`
  67. runuser=`whoami`
  68.  
  69. if [ $runuser != $dumpuser ]; then
  70.     echo "amdump: must be run as user $dumpuser"
  71.     exit 1
  72. fi
  73.  
  74. if test -f hold; then
  75.     echo "amdump: waiting for hold file to be removed" >&2
  76.     while test -f hold; do
  77.         sleep 60
  78.     done
  79. fi
  80.  
  81. if test -f $errfile || test -f $logdir/log; then
  82.     echo "amdump: amdump or amflush is already running, or you must run amcleanup" >&2
  83.     exit 1
  84. fi
  85.  
  86. umask 077
  87.  
  88. # Plan and drive the dumps.
  89. exec </dev/null >$errfile 2>&1
  90. echo "amdump: start at `date`"
  91. $libexecdir/planner$SUF | $libexecdir/driver$SUF
  92. echo "amdump: end at `date`"
  93.  
  94. # Send out a report on the dumps.
  95. exec </dev/null >/dev/null 2>&1
  96. $sbindir/amreport$SUF
  97.  
  98. # Keep a debug log through the tapecycle plus a couple of days.
  99. maxdays=`expr $tapecycle + 2`
  100. days=1
  101. # First, find out the last existing errfile,
  102. # to avoid ``infinite'' loops if tapecycle is infinite
  103. while [ $days -lt $maxdays ] && [ -f $errfile.$days ]; do
  104.     days=`expr $days + 1`
  105. done
  106. # Now, renumber the existing log files
  107. while [ $days -ge 2 ]; do
  108.     ndays=`expr $days - 1`
  109.     mv $errfile.$ndays $errfile.$days
  110.     days=$ndays
  111. done
  112. mv $errfile $errfile.1
  113.  
  114. # Trim the index file to those for dumps that still exist.
  115. $libexecdir/amtrmidx$SUF $conf
  116.  
  117. exit 0
  118.